package base.signals;

import org.redr.canvas.RRW;
import org.redr.canvas.utils.OutputSocketDataException;


public class RMatrixOutput extends ROutputSocket {

	public RMatrixOutput(RRW widget, String signalId, String n) {
		super(widget, signalId, n);
		this.connectionTypes.add("RDataFrame");
		this.connectionTypes.add("RList");
		this.connectionTypes.add("RMatrix");
	}

	@Override
	public void setData(Object data) throws OutputSocketDataException {
		this.data = data;
	}

	@Override
	public Object getData() {
		return this.data;
	}

	@Override
	public Object getData(String signalType) throws OutputSocketDataException {
		if (!this.connectionTypes.contains(signalType)) throw new OutputSocketDataException("No compatible signal of type " + signalType); 
		if (signalType.equals("RDataFrame")) return String.format("as.data.frame(%s)", this.data);
		return this.data;
	}

}
